# float是不精确的数据
# why? 二进制的数据
# 2 => 10
# 1 => 01
# 0.5
# 浮点型数据比较时需要特别注意
num = 1
i = 0.1
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
print()
# 输出结果:
# 0.9
# 0.8
# 0.7000000000000001
# 0.6000000000000001
# 0.5000000000000001
# 0.40000000000000013
# 0.30000000000000016

# 有些场合时不能使用float的？ 钱
# decimal是精确的浮点数
# decimal => 当我们需要精确的数据时
# float 0.1 在内存存储之后，到底是多少呢？
from decimal import Decimal
# float的0.1
i = Decimal(0.1)
print(i)
# 精确的0.1
i = Decimal('0.1')
print(i)

num = 1
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
num = num - i
print(num)
# 输出结果：
# 0.1000000000000000055511151231257827021181583404541015625
# 0.1
# 0.9
# 0.8
# 0.7
# 0.6
# 0.5
# 0.4
# 0.3